﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Core;
public partial class BaoCao_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {


            ReportViewer1.LocalReport.DisplayName = "DanhSachCanBo";
            ReportViewer1.LocalReport.ReportPath = "BaoCao/Report.rdlc";
            ReportViewer1.LocalReport.DataSources.Clear();

            switch (BaoCao)
            {
                case "CanBoDonVi":

                    if (Request.QueryString["MaDonVi"] != null && Request.QueryString["MaDonVi"]!="")
                    {
                        var odsAll1 = new ObjectDataSource("Core.CanBo", "All_CanBoTheoDonVi");
                        odsAll1.SelectParameters.Add("maDonVi", System.Data.DbType.Int32, Request.QueryString["MaDonVi"]);
                        var rpDataSource1 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll1);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource1);
                    }
                    else
                    {
                        var odsAll2 = new ObjectDataSource("Core.CanBo", "All");
                        var rpDataSource2 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll2);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource2);
                    }

                    break;
                case "TheoTuoi":

                    if (Request.QueryString["Tuoi"] != null && Request.QueryString["Tuoi"] != "")
                    {
                        var odsAll1 = new ObjectDataSource("Core.CanBo", "All_CanBoTheoTuoi");
                        odsAll1.SelectParameters.Add("tuoi", System.Data.DbType.Int32, Request.QueryString["Tuoi"]);
                        var rpDataSource1 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll1);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource1);
                    }
                    else
                    {
                        var odsAll2 = new ObjectDataSource("Core.CanBo", "All");
                        var rpDataSource2 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll2);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource2);
                    }

                    break;
                case "CanBoTheoLoaiCanBo":

                    if (Request.QueryString["MaLoaiCB"] != null && Request.QueryString["MaLoaiCB"] != "")
                    {
                        var odsAll1 = new ObjectDataSource("Core.CanBo", "All_CanBoTheoLoaiCanBo");
                        odsAll1.SelectParameters.Add("maLoaiCB", System.Data.DbType.Int32, Request.QueryString["MaLoaiCB"]);
                        var rpDataSource1 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll1);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource1);
                    }
                    else
                    {
                        var odsAll2 = new ObjectDataSource("Core.CanBo", "All");
                        var rpDataSource2 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll2);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource2);
                    }

                    break;
                case "CanBoTheoNgach":

                    if (Request.QueryString["MaNgach"] != null && Request.QueryString["MaNgach"] != "")
                    {
                        var odsAll1 = new ObjectDataSource("Core.CanBo", "All_CanBoTheoNgach");
                        odsAll1.SelectParameters.Add("maNgach", System.Data.DbType.Int32, Request.QueryString["MaNgach"]);
                        var rpDataSource1 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll1);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource1);
                    }
                    else
                    {
                        var odsAll2 = new ObjectDataSource("Core.CanBo", "All");
                        var rpDataSource2 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll2);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource2);
                    }

                    break;
                case "CanBoTheoBangCap":

                    if (Request.QueryString["MaBangCap"] != null && Request.QueryString["MaBangCap"] != "")
                    {
                        var odsAll1 = new ObjectDataSource("Core.CanBo", "All_CanBoTheoBangCap");
                        odsAll1.SelectParameters.Add("maBangCap", System.Data.DbType.Int32, Request.QueryString["MaBangCap"]);
                        var rpDataSource1 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll1);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource1);
                    }
                    else
                    {
                        var odsAll2 = new ObjectDataSource("Core.CanBo", "All");
                        var rpDataSource2 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll2);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource2);
                    }

                    break;
                case "CanBoTheoHeSoLuong":

                    if (Request.QueryString["HeSoLuong"] != null && Request.QueryString["HeSoLuong"] != "")
                    {
                        var odsAll1 = new ObjectDataSource("Core.CanBo", "All_CanBoTheoHeSoLuong");
                        odsAll1.SelectParameters.Add("heSoLuong", System.Data.DbType.Int32, Request.QueryString["HeSoLuong"]);
                        var rpDataSource1 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll1);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource1);
                    }
                    else
                    {
                        var odsAll2 = new ObjectDataSource("Core.CanBo", "All");
                        var rpDataSource2 = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll2);

                        ReportViewer1.LocalReport.DataSources.Add(rpDataSource2);
                    }

                    break;
                case "CanBoKhenThuong":
                    var odsAll = new ObjectDataSource("Core.CanBo", "All_CanBoDuocKhenThuong");
                    var rpDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll);

                    ReportViewer1.LocalReport.DataSources.Add(rpDataSource);

                    break;
                case "CanBoKyLuat":
                    odsAll = new ObjectDataSource("Core.CanBo", "All_CanBoBiKyLuat");
                    rpDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll);

                    ReportViewer1.LocalReport.DataSources.Add(rpDataSource);

                    break;

                case "CanBoSapVeHuu":
                    odsAll = new ObjectDataSource("Core.CanBo", "All_CanBoSapVeHuu");
                    rpDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll);

                    ReportViewer1.LocalReport.DataSources.Add(rpDataSource);

                    break;
                case "CanBoDangVien":
                     odsAll = new ObjectDataSource("Core.CanBo", "All_CanBoDangVien");
                    rpDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll);

                    ReportViewer1.LocalReport.DataSources.Add(rpDataSource);
                    break;
                default:

                    odsAll = new ObjectDataSource("Core.CanBo", "All");
                    rpDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", odsAll);

                    ReportViewer1.LocalReport.DataSources.Add(rpDataSource);
                    break;
            }
        }
    }
    string BaoCao
    {
        get
        {
            if (Request.QueryString["BaoCao"] != null)
                return Request.QueryString["BaoCao"];
            return string.Empty;
        }
    }
}